﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using compshop.Infrastructure.CompShopDataService;

namespace compshop.Modules.ListOfSuppliers.View
{
    /// <summary>
    /// Логика взаимодействия для EditSupplierView.xaml
    /// </summary>
    public partial class EditSupplierView : Window
    {
        private void Initialize()
        {
            DataContext = this;
            InitializeComponent();
            btnCancel.Click += new RoutedEventHandler(btnCancel_Click);
            btnOk.Click += new RoutedEventHandler(btnOk_Click);
        }

        void btnOk_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
            supplier.Address = txbAddress.Text;
            supplier.BankAccount = txbBankAccount.Text;
            supplier.DelegateName = txbDelegateName.Text;
            supplier.DelegatePosition = txbDelegatePosition.Text;
            supplier.Email = txbEmail.Text;
            supplier.Name = txbName.Text;
            supplier.Phone = txbPhone.Text;
            this.Close();
        }

        void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
            this.Close();
        }
        public EditSupplierView()
        {
            supplier = new Supplier();
            Initialize();
        }
        public EditSupplierView(Supplier editingSupplier)
        {
            supplier = editingSupplier;
            Initialize();
        }
        public Supplier supplier{get;set;}
    }
}
